package com.haois.mp;

import com.google.common.base.Joiner;
import com.haois.mp.database.module.basic.util.SpringContextHolder;
import com.haois.mp.wechat.config.MenuConfig;
import me.chanjar.weixin.common.bean.menu.WxMenu;
import me.chanjar.weixin.mp.api.WxMpMenuService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Created by RuiHaoZ on GCU
 *
 * @author RuiHaoZ
 * @date 2017/11/22
 */
@MapperScan("com.haois.mp.database.module.*.dao")
@SpringBootApplication(scanBasePackages = "com.haois.mp")
@EnableTransactionManagement(proxyTargetClass = true)
public class Application extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }


}
// TODO: 2017/12/3 发布服务器请选择上面的
//public class Application  extends WebMvcConfigurerAdapter {
//
//    public static void main(String[] args) {
//        SpringApplication.run(mp.Application.class, args);
//    }
//
//    @Bean
//    public MenuConfig menuConfig() {
//        return new MenuConfig();
//    }
//
//    @Bean
//    public InitializingBean initDefaultMenu() {
//        return new InitializingBean() {
//
//            @Autowired
//            private WxMpMenuService WxMpMenuService;
//
//            @Override
//            public void afterPropertiesSet() throws Exception {
//                WxMenu wxMenu = menuConfig().createWxMenu();
//                WxMpMenuService.menuCreate(wxMenu);
//            }
//        };
//    }
//
//}
